/********************************************************************
	created:	2011/04/17
	created:	17:4:2011   18:37
	filename: 	d:\Work\Job\trunk\Speed\LogicDriver.h
	file path:	d:\Work\Job\trunk\Speed
	file base:	LogicDriver
	file ext:	h
	author:		liang
	
	purpose:	
*********************************************************************/
#ifndef _LogicDriver_h_2011_04_17_18_37
#define _LogicDriver_h_2011_04_17_18_37

#include <string>
#include <vector>

using namespace std;

#define MAXBUF 512
struct LogicDeviceInfo
{
	char LogicDeviceName[MAXBUF];
	unsigned long SectorsPerCluster;
	unsigned long BytesPerSector;
	unsigned long NumberOfFreeClusters;
	unsigned long TotalNumberOfClusters;
	unsigned int DeviceType;

	//
	char VolumeName[MAXBUF];
	unsigned long VolumeSerialNumber;
	unsigned long MaximumComponentLength;
	unsigned long FileSystemFlags;
	char FileSystemNameBuffer[MAXBUF];

	LogicDeviceInfo()
	{
		LogicDeviceName[0] = '\0';
		SectorsPerCluster = 0;
		BytesPerSector = 0;
		NumberOfFreeClusters = 0;
		TotalNumberOfClusters = 0;
		DeviceType = 0;

		VolumeName[0] = '\0';
		VolumeSerialNumber = 0;
		MaximumComponentLength = 0;
		FileSystemFlags = 0;
		FileSystemNameBuffer[0] = '\0';
	}

	bool operator == (const LogicDeviceInfo& other) const
	{
		return stricmp(this->LogicDeviceName,other.LogicDeviceName) == 0;
	}
};

class LogicDriver
{
public:
	static LogicDriver* GetInstance();
	static void Release();

	bool IsValidDish(const char* pDiskName);
	unsigned long long FreeVolume(const char* pDiskName);
	unsigned long long TotalVolume(const char* pDiskName);

private:
	LogicDriver();
	~LogicDriver();

	bool UpdateDriverInfo();

	typedef vector<string> LogicDeviceNameVec;
	LogicDeviceNameVec m_LogicDeviceNameVec;

	typedef vector<LogicDeviceInfo> LogicDeviceInfoVec;
	LogicDeviceInfoVec m_LogicDeviceInfoVec;

	static LogicDriver* s_pInstance;
};



#endif